<template>
    web worker
    <el-button @click="save" type="primary">保存</el-button>
</template>
<script setup lang="ts">
import { onMounted } from "vue";

const url = new URL("./worker.ts", import.meta.url);
const saveWorker = new Worker(
    url,
    {
        type: "module",
    }
);
saveWorker.onmessage = (e: any) => {
    if (e.data.error) {
        console.error("自动保存失败，请联系管理员！");
    } else {
        console.log("自动保存成功！");
    }
};
const save = () => {
    saveWorker.postMessage({
        frameData: { a: 1, b: 2 },
        editorToken: "123456",
    });

}
onMounted(() => {
})
</script>

<style lang="scss"></style>